#include <iostream>
using namespace std;

int n,m;
const int N=1e5+10;
int cnt[N];
int count=0;
int main() {
    
    cin>>n>>m;
    while(n--){
        int num;
        cin>>num;
        cnt[num]++;
    }
    for(int i=0;i<N;i++){
        if(cnt[i]>0) ++count;
        
    }
    if(count>m) cout<<-1<<endl;
    
    return 0;
}
